//
//  Event.m
//  SmallEasyLife
//
//  Created by qianfeng on 15/10/24.
//  Copyright © 2015年 GXK. All rights reserved.
//

#import "Event.h"
#import "Allshop.h"

@implementation Event

+ (instancetype)eventWithDictionary:(NSDictionary *)dictionary
{
    Event * instance = [[Event alloc] initWithDictionary:dictionary];
    return instance;
}

//initWithDictionary:
- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    if (self = [super init]) {
        if(nil != [dictionary objectForKey: @"feeltitle"])
        {
            self.feeltitle = [dictionary objectForKey: @"feeltitle"];
        }
        
        if(nil != [dictionary objectForKey: @"position"])
        {
            self.position = [dictionary objectForKey: @"position"];
        }
        
        if(nil != [dictionary objectForKey: @"title"])
        {
            self.title = [dictionary objectForKey: @"title"];
        }
        
        if(nil != [dictionary objectForKey: @"mobileURL"])
        {
            self.mobileURL = [dictionary objectForKey: @"mobileURL"];
        }
        
        if(nil != [dictionary objectForKey: @"telephone"])
        {
            self.telephone = [dictionary objectForKey: @"telephone"];
        }
        
        if(nil != [dictionary objectForKey: @"feelnum"])
        {
            self.feelnum = [dictionary objectForKey: @"feelnum"];
        }
        
        if(nil != [dictionary objectForKey: @"startdate"])
        {
            self.startdate = [dictionary objectForKey: @"startdate"];
        }
        
        if(nil != [dictionary objectForKey: @"allshops"])
        {
            NSArray * allShops = [dictionary objectForKey: @"allshops"];
            NSMutableArray * allShopsMArr = [[NSMutableArray alloc] initWithCapacity:allShops.count];
            for (NSDictionary * modelDic in allShops) {
                Allshop * shop = [Allshop allshopWithDictionary:modelDic];
                [allShopsMArr addObject:shop];
            }
            self.allshops = allShopsMArr;
        }
        
        if(nil != [dictionary objectForKey: @"city"])
        {
            self.city = [dictionary objectForKey: @"city"];
        }
        
        if(nil != [dictionary objectForKey: @"shareURL"])
        {
            self.shareURL = [dictionary objectForKey: @"shareURL"];
        }
        
        if(nil != [dictionary objectForKey: @"tag"])
        {
            self.tag = [dictionary objectForKey: @"tag"];
        }
        
        if(nil != [dictionary objectForKey: @"enddate"])
        {
            self.enddate = [dictionary objectForKey: @"enddate"];
        }
        
        if(nil != [dictionary objectForKey: @"eventtype"])
        {
            self.eventtype = [dictionary objectForKey: @"eventtype"];
        }
        
        if(nil != [dictionary objectForKey: @"feel"])
        {
            self.feel = [dictionary objectForKey: @"feel"];
        }
        
        if(nil != [dictionary objectForKey: @"imgs"])
        {
            self.imgs = [dictionary objectForKey: @"imgs"];
        }
        
        if(nil != [dictionary objectForKey: @"id"])
        {
            self.identifier = [dictionary objectForKey: @"id"];
        }
        
        if(nil != [dictionary objectForKey: @"islongtime"])
        {
            self.islongtime = [dictionary objectForKey: @"islongtime"];
        }
        
        if(nil != [dictionary objectForKey: @"adurl"])
        {
            self.adurl = [dictionary objectForKey: @"adurl"];
        }
        
        if(nil != [dictionary objectForKey: @"eid"])
        {
            self.eid = [dictionary objectForKey: @"eid"];
        }
        
        if(nil != [dictionary objectForKey: @"cat"])
        {
            self.cat = [Cat catWithDictionary: [dictionary objectForKey: @"cat"]];
        }
        
//        if(nil != [dictionary objectForKey: @"more"])
//        {
//            self.more = [More MoreWithArray: [dictionary objectForKey: @"more"]];
//        }
        
        if(nil != [dictionary objectForKey: @"note"])
        {
            self.note = [dictionary objectForKey: @"note"];
        }
        
        if(nil != [dictionary objectForKey: @"detail"])
        {
            self.detail = [dictionary objectForKey: @"detail"];
        }
        
        if(nil != [dictionary objectForKey: @"questionURL"])
        {
            self.questionURL = [dictionary objectForKey: @"questionURL"];
        }
        
        if(nil != [dictionary objectForKey: @"sponsor"])
        {
            self.sponsor = [Sponsor sponsorWithDictionary: [dictionary objectForKey: @"sponsor"]];
        }
        
        if(nil != [dictionary objectForKey: @"remark"])
        {
            self.remark = [dictionary objectForKey: @"remark"];
        }
        
        if(nil != [dictionary objectForKey: @"address"])
        {
            self.address = [dictionary objectForKey: @"address"];
        }
    }
    return self;
}//end initWithDictionary:

//description
- (NSString*) description
{
    NSMutableString * descriptionOutput = [[NSMutableString alloc] init];
    [descriptionOutput appendFormat: @"feeltitle = \"%@\"\r\n", self.feeltitle];
    [descriptionOutput appendFormat: @"position = \"%@\"\r\n", self.position];
    [descriptionOutput appendFormat: @"title = \"%@\"\r\n", self.title];
    [descriptionOutput appendFormat: @"mobileURL = \"%@\"\r\n", self.mobileURL];
    [descriptionOutput appendFormat: @"telephone = \"%@\"\r\n", self.telephone];
    [descriptionOutput appendFormat: @"feelnum = \"%@\"\r\n", self.feelnum];
    [descriptionOutput appendFormat: @"startdate = \"%@\"\r\n", self.startdate];
    [descriptionOutput appendFormat: @"allshops = \"%@\"\r\n", self.allshops];
    [descriptionOutput appendFormat: @"city = \"%@\"\r\n", self.city];
    [descriptionOutput appendFormat: @"shareURL = \"%@\"\r\n", self.shareURL];
    [descriptionOutput appendFormat: @"tag = \"%@\"\r\n", self.tag];
    [descriptionOutput appendFormat: @"enddate = \"%@\"\r\n", self.enddate];
    [descriptionOutput appendFormat: @"eventtype = \"%@\"\r\n", self.eventtype];
    [descriptionOutput appendFormat: @"feel = \"%@\"\r\n", self.feel];
    [descriptionOutput appendFormat: @"imgs = \"%@\"\r\n", self.imgs];
    [descriptionOutput appendFormat: @"id = \"%@\"\r\n", self.identifier];
    [descriptionOutput appendFormat: @"islongtime = \"%@\"\r\n", self.islongtime];
    [descriptionOutput appendFormat: @"adurl = \"%@\"\r\n", self.adurl];
    [descriptionOutput appendFormat: @"eid = \"%@\"\r\n", self.eid];
    [descriptionOutput appendFormat: @"cat: { %@ }\r\n", self.cat];
    [descriptionOutput appendFormat: @"more = \"%@\"\r\n", self.more];
    [descriptionOutput appendFormat: @"note = \"%@\"\r\n", self.note];
    [descriptionOutput appendFormat: @"detail = \"%@\"\r\n", self.detail];
    [descriptionOutput appendFormat: @"questionURL = \"%@\"\r\n", self.questionURL];
    [descriptionOutput appendFormat: @"sponsor: { %@ }\r\n", self.sponsor];
    [descriptionOutput appendFormat: @"remark = \"%@\"\r\n", self.remark];
    [descriptionOutput appendFormat: @"address = \"%@\"\r\n", self.address];
    
    return descriptionOutput;
}//end description

@end
